package com.roc.web.action.merinfo;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class MerinfoManageSearchCondition extends BaseSearchCondition{
	
	private String merchantNo;//商户号
	private String merchantName;//商户简称
	private String  merBrName; //注册名称
	private String  minDate;//入网时间
	private String  maxDate;//入网时间
	private String  certifName;//法人
	private String  cardNo; //法人身份证
	private String  contactName;//业务联系人
	private String  phone;//联系电话
	
	private String opId;    //操作员id
	
	private String association; //商户连接方式（0：间连，1：直连）
	private String grade;       //商户等级 A,B,C,D,E,F;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if(Constance.isNotEmpty(grade)&&!"99".equals(grade)){ //商户等级
			filedBeanList.add(new WhereHQLFieldBean("A.isgroup", grade.trim(), "=", false));
		}
		if(Constance.isNotEmpty(association)&&!"99".equals(association)){ //商户连接方式
			filedBeanList.add(new WhereHQLFieldBean("A.group_cd", association.trim(), "=", false));
		}
		
		if(Constance.isNotEmpty(merchantNo)){ //商户号
			filedBeanList.add(new WhereHQLFieldBean("A.MCHT_CD", merchantNo.trim(), "=", false));
		}
		
		filedBeanList.add(new WhereHQLFieldBean( "A.BANK_BELONG_CD IN ( SELECT org_code  FROM   t_operators  WHERE  ID="+opId.trim()+")"));
		
		if(Constance.isNotEmpty(merBrName)){ //商户名称 （模糊）
			filedBeanList.add(new WhereHQLFieldBean("A.NAME", merBrName.trim(), "like", false,"ALL"));
		}
		
		if(Constance.isNotEmpty(merchantName)){ //商户名称 （模糊）
			filedBeanList.add(new WhereHQLFieldBean("A.NAME_BUSI", merchantName.trim(), "like", false,"ALL"));
		}
		
		if(Constance.isNotEmpty(minDate)&&Constance.isNotEmpty(maxDate)){ //入网时间
			filedBeanList.add(new WhereHQLFieldBean("A.APPL_DATE",minDate,">=", false));
       	    filedBeanList.add(new WhereHQLFieldBean("A.APPL_DATE",maxDate,"<=", false));
		}
	
		if(Constance.isNotEmpty(certifName)){ //法人
			filedBeanList.add(new WhereHQLFieldBean("A.CERTIF", certifName.trim(), "like", false,"ALL"));
		}
		if(Constance.isNotEmpty(cardNo)){ //法人身份证号
			filedBeanList.add(new WhereHQLFieldBean("A.CERTIF_NO", cardNo.trim(), "=", false));
		}
		if(Constance.isNotEmpty(contactName)){ //业务联系人
			filedBeanList.add(new WhereHQLFieldBean("A.CONTACT_NAME", contactName.trim() ,"like", false,"ALL"));
		} 
		if(Constance.isNotEmpty(phone)){ //业务联系电话
			filedBeanList.add(new WhereHQLFieldBean("A.CONTACT_PHONENO", phone.trim(), "=", false));
		} 
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		// TODO Auto-generated method stub
		StringBuffer  sb= new StringBuffer();		

			sb.append(" SELECT COUNT(1) ")
			.append("  FROM tbl_mcht_inf  A  WHERE 1=1 ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		StringBuffer  sb= new StringBuffer();	
		sb.append("SELECT A.MCHT_CD,A.NAME_BUSI,A.NAME MERNAME,A.isgroup,A.group_cd,A.CONTACT_NAME,A.CONTACT_PHONENO,A.CERTIF,A.CERTIF_NO,  ")
		  .append("  A.BUSI_LICE_NO,A.REG_ADDR,A.STATUS   ")
		  .append("  FROM tbl_mcht_inf A  where 1=1 ");

          return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return "ORDER BY  A.REC_APLLY_TS ASC ";
	}

	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	public String getMerchantName() {
		return merchantName;
	}

	public void setMerchantName(String merchantName) {
		this.merchantName = merchantName;
	}

	public String getMerBrName() {
		return merBrName;
	}

	public void setMerBrName(String merBrName) {
		this.merBrName = merBrName;
	}

	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getCertifName() {
		return certifName;
	}

	public void setCertifName(String certifName) {
		this.certifName = certifName;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getContactName() {
		return contactName;
	}

	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAssociation() {
		return association;
	}

	public void setAssociation(String association) {
		this.association = association;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public String getOpId() {
		return opId;
	}

	public void setOpId(String opId) {
		this.opId = opId;
	}

	

	
	

}
